from PIL import Image

image = Image.open("test.png")

out = image.transpose(Image.Transpose.ROTATE_90)
out.save("test_rotated.png")